//
//  UIBarButtonItem+Extension.swift
//  新浪微博
//
//  Created by mac on 16/5/21.
//  Copyright © 2016年 mac.com. All rights reserved.
//

import  UIKit
extension UIBarButtonItem{
    convenience init(imagename: String? = nil,title: String? = nil, target:AnyObject?,action:Selector ) {
        self.init()
        
        let btn = UIButton()
        if let img = imagename {
        btn.setImage(UIImage(named: img), forState: .Normal)
            btn.setImage(UIImage(named: img + "_highlighted"), forState: .Highlighted)
        }
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        btn.setTitle(title, forState: .Normal)
        btn.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btn.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        btn.sizeToFit()
        self.customView = btn
    }





}
